package com.wc.AlgoOJ_train.train1.c6.A602;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/1/10 21:02
 * @description
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            if (isRight(sc.next())) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
    }

    static boolean isRight(String s) {
        char[] chs = s.toCharArray();
        if (judgeNum(chs[0]) || !judge(chs[0])) {
            return false;
        }

        for (int i = 1; i < chs.length; i++) {
            if (!judge(chs[i]) && !judgeNum(chs[i])) {
                return false;
            }
        }
        return true;
    }

    static boolean judge(char ch) {
        return ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch == '$';
    }

    static boolean judgeNum(char ch) {
        return ch >= '0' && ch <= '9';
    }
}
